//
//  UIBarButtonItem+GTQInit.m
//  GTQBaisiNews
//
//  Created by 光头强 on 16/5/11.
//  Copyright © 2016年 Ls. All rights reserved.
//

#import "UIBarButtonItem+GTQInit.h"
#import "UIView+GTQFrame.h"

@implementation UIBarButtonItem (GTQInit)

/**
 * 包装按钮为UIBarButtonItem
 */
+ (UIBarButtonItem *)barButtonItemWithImage:(NSString *)image highlightImage:(NSString *)highlightImage target:(nullable id)target action:(nullable SEL)action {
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    if (highlightImage) {
         [button setBackgroundImage:[UIImage imageNamed:highlightImage] forState:UIControlStateHighlighted];
    }
    button.size = button.currentBackgroundImage.size;
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc] initWithCustomView:button];
}
@end
